<? session_start();

include "SVsystem/class/remoteFunctions.php";
include("SVsystem/config/dbconfig.php"); ////////setup
include("SVsystem/config/dominio.php");
includeCommonClass("formulario");
includeCommonClass("funciones");


$tool = new formulario('db');


     switch ($_REQUEST['nivel']) {
	  case 1:
		 $tabla = "prod_categoria";
		 $nivelc = 2;
		 break;
	  case 2:
		 $tabla = "prod_subcategoria";
		 $nivelc = 3;
		 break;
	  }


///////////categoria de productos
		$catealink = " (CASE {$_REQUEST['nivel']} WHEN '1' THEN
		  (SELECT DISTINCT
		  concat('<a href=\"SV-listado-categorias.php?nivel=1&catid=',c.id,'\">',c.nombre,'</a>')
		FROM
		  prod_categoria c
		WHERE
		 c.id = a.id)
		   WHEN '2' THEN

		(SELECT DISTINCT
		  /* concat(c.nombre,'&gt;',s.nombre)*/
		  concat('<a href=\"SV-listado-categorias.php?nivel=1&catid=',c.id,'\">',c.nombre,'</a>',' &gt; ','<a href=\"SV-listado-productos.php?nivel=2&catid=',s.id,'\">',s.nombre,'</a>')
		FROM
		  prod_categoria c
		  INNER JOIN prod_subcategoria s ON (s.cat_id = c.id)
		WHERE
		  s.id = a.id)

			ELSE

		 (SELECT DISTINCT
		/*  concat(c.nombre, '&gt;', s.nombre,'&gt;', ss.nombre) */
		 concat('<a href=\"SV-listado-categorias.php?nivel=1&catid=',c.id,'\">',c.nombre,'</a>',' &gt; ','<a href=\"SV-listado-categorias.php?nivel=2&catid=',s.id,'\">',s.nombre,'</a>',' &gt; ','<a href=\"SV-listado-productos.php?nivel=3&catid=',ss.id,'\">',ss.nombre,'</a>')
		FROM
		   prod_sub_subcategoria ss
		  INNER JOIN prod_subcategoria s ON (ss.sub_id = s.id)
		  INNER JOIN prod_categoria c ON (s.cat_id = c.id)
		WHERE
		  ss.id = a.id)

			 END) as categoria";



	$datacat2 = $tool->simple_db("select *,$catealink from $tabla a where id = '{$_REQUEST['catid']}' ");


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
	"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title><?php echo utf8_encode($datacat2['nombre']); ?></title>
	<link rel="stylesheet" href="estilo.css" type="text/css" media="screen" title="no title" charset="utf-8">
<!--[if IE]> <link href="ie-shit.css" rel="stylesheet" type="text/css"> <![endif]-->
	<script src="/SVscripts/jquery-1.5.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="/SVscripts/menu.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="SVsystem/js/utils.js"></script>
<script type="text/javascript" src="SVsystem/js/ajax.js"></script>
</head>
<body class="interno">

<div id="wrapper">
<?php include ("SVG-barrahorizontal.php")?>

<div id="tapatope"></div>





<div id="contenido">


<div id="izquierda">

<?php include('SVG-menu-categorias.php'); ?>

</div>


<!-- centro -->
<div id="centro">

<div id="nav" >
<a href="javascript:history.back();" title="Volver"><img src="http://www.svcmscentral.com/admin/icon/icon-volver.png" border="0"  alt="volver"/></a>

<a href="index.php" title="Subir"><img src="http://www.svcmscentral.com/admin/icon/icon-subir.png" border="0"  alt="subir"/></a>

<div id="separador"></div>
</div>


<h1><?php echo utf8_encode($datacat2['nombre']); ?></h1>
<p><?php echo utf8_encode($datacat2['descrip']); ?></p>
<div id="separador" style="height:30px;"></div>
<div id="destacados">


                 <?php

					 if($nivelc==2){

						 $query="select id,nombre,imagen,descrip,(select count(*) from prod_sub_subcategoria where sub_id = s.id ) as ssub,descrip from prod_subcategoria s where cat_id = '{$_REQUEST['catid']}'";

					 }else  if($nivelc==3){

						 $query="select id,nombre,imagen,descrip,'0' as ssub,descrip from prod_sub_subcategoria s where sub_id = '{$_REQUEST['catid']}'";

					 }

					 if(isset($_REQUEST['orden'])) $query.=" order by ".$_REQUEST['orden']; else $query.=" order by orden";

					 $tool->query($query);

				 		while ($row = mysql_fetch_assoc($tool->result)) {

							if($row['ssub']>0) $link = "SV-listado-categorias.php?nivel=$nivelc&catid=".$row['id']; else $link = "SV-listado-productos.php?nivel=$nivelc&catid=".$row['id'];
							if(empty($row['imagen'])) $row['imagen'] = 'noimagen.jpg';
					 ?>



<div  id="item-articulo">
					<a href="<?php echo $link; ?>" title="<?php echo utf8_encode($row['nombre']); ?>">
<div id="imagen" style="background-image:url('<?php echo $DOMINIOSV ?>/categoria/turn/<?php echo $row['imagen'] ?>');" title="<?php echo utf8_encode($row['nombre']); ?>"></div>




</a>
					<h2><a href="<?php echo $link; ?>"><?php echo utf8_encode($row['nombre']); ?></a></h2>
                    <p><?php echo utf8_encode($row['descrip']); ?></a></p>
				</div>

                 <?php } $tool->liberar(); ?>
<div id="separador"></div>
			</div>




</div>



<!-- columna derecha aqui -->
		<div id="derecha">

<?php include ("SVG-loginbox.php")?>
<?php include ("SVG-banners0.php")?>

</div>





<div id="separador"></div>
	</div>


</div>
<?php include('SVG-footer.php'); ?>


















</body>















</html>
<? $tool->cerrar(); ?>